home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / form1.vb < prev    next >
Encoding:
Text File  |  2004-07-15  |  23.1 KB  |  578 lines

  1. '******************************************************************'
  2. '*                                                                *'
  3. '*                      TurboCAD for Windows                      *'
  4. '*                   Copyright (c) 1993 - 2004                    *'
  5. '*             International Microcomputer Software, Inc.         *'
  6. '*                            (IMSI)                              *'
  7. '*                      All rights reserved.                      *'
  8. '*                                                                *'
  9. '******************************************************************'
  10. Public Enum ActiveTool
  11.     iSelectTool = 0
  12.     iAddLineSingleTool = 1
  13.     iAddCircleCenterAndPoint = 2
  14. End Enum
  15.  
  16. Public Class Form1
  17.     Inherits System.Windows.Forms.Form
  18.     Const sTitle = "TCGeometry sample application !"
  19.     Dim firstPointX As Integer
  20.     Dim firstPointY As Integer
  21.     Dim previousMoveX As Integer
  22.     Dim previousMoveY As Integer
  23.     Dim pGraphics As System.Drawing.Graphics
  24.     Dim pPen As System.Drawing.Pen
  25.     Dim pPenBackground As System.Drawing.Pen
  26.     Dim tcApp As TCEngine
  27.     Dim m_bDrag As Boolean
  28.     Dim m_iActiveTool As ActiveTool
  29.     Dim m_BackgroundColor As System.Drawing.Color
  30.  
  31.  
  32. #Region " Windows Form Designer generated code "
  33.  
  34.     Public Sub New()
  35.         MyBase.New()
  36.  
  37.         'This call is required by the Windows Form Designer.
  38.         InitializeComponent()
  39.  
  40.         'Add any initialization after the InitializeComponent() call
  41.  
  42.         pGraphics = picView.CreateGraphics()
  43.  
  44.         pGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
  45.         'pGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality 
  46.         pPen = New Pen(System.Drawing.Color.Blue, 1)
  47.         '//pPenBackground = new Pen (picView.BackColor  ,1)
  48.         EnableButtons(False)
  49.         tcApp = New TCEngine
  50.         firstPointX = -1
  51.         firstPointY = -1
  52.         previousMoveX = -1
  53.         previousMoveY = -1
  54.         m_bDrag = False
  55.         m_iActiveTool = ActiveTool.iSelectTool
  56.  
  57.     End Sub
  58.  
  59.     'Form overrides dispose to clean up the component list.
  60.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  61.         If disposing Then
  62.             If Not (components Is Nothing) Then
  63.                 components.Dispose()
  64.             End If
  65.         End If
  66.         MyBase.Dispose(disposing)
  67.     End Sub
  68.  
  69.     'Required by the Windows Form Designer
  70.     Private components As System.ComponentModel.IContainer
  71.  
  72.     'NOTE: The following procedure is required by the Windows Form Designer
  73.     'It can be modified using the Windows Form Designer.  
  74.     'Do not modify it using the code editor.
  75.     Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
  76.     Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
  77.     Friend WithEvents cmCreateTCApp As System.Windows.Forms.Button
  78.     Friend WithEvents cmNewDrawing As System.Windows.Forms.Button
  79.     Friend WithEvents cmCloseDrawing As System.Windows.Forms.Button
  80.     Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
  81.     Friend WithEvents cmZoomIn As System.Windows.Forms.Button
  82.     Friend WithEvents cmZoomOut As System.Windows.Forms.Button
  83.     Friend WithEvents cmZoomExtents As System.Windows.Forms.Button
  84.     Friend WithEvents cmCreateLine As System.Windows.Forms.Button
  85.     Friend WithEvents cmCreateCircle As System.Windows.Forms.Button
  86.     Friend WithEvents cmSelect As System.Windows.Forms.Button
  87.     Friend WithEvents label2 As System.Windows.Forms.Label
  88.     Friend WithEvents label3 As System.Windows.Forms.Label
  89.     Friend WithEvents propsPalette As System.Windows.Forms.TreeView
  90.     Friend WithEvents label1 As System.Windows.Forms.Label
  91.     Friend WithEvents cmRefresh As System.Windows.Forms.Button
  92.     Private WithEvents picView As System.Windows.Forms.PictureBox
  93.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  94.         Me.GroupBox1 = New System.Windows.Forms.GroupBox
  95.         Me.cmCreateTCApp = New System.Windows.Forms.Button
  96.         Me.GroupBox2 = New System.Windows.Forms.GroupBox
  97.         Me.cmNewDrawing = New System.Windows.Forms.Button
  98.         Me.cmCloseDrawing = New System.Windows.Forms.Button
  99.         Me.picView = New System.Windows.Forms.PictureBox
  100.         Me.StatusBar1 = New System.Windows.Forms.StatusBar
  101.         Me.propsPalette = New System.Windows.Forms.TreeView
  102.         Me.cmZoomIn = New System.Windows.Forms.Button
  103.         Me.cmZoomOut = New System.Windows.Forms.Button
  104.         Me.cmZoomExtents = New System.Windows.Forms.Button
  105.         Me.cmCreateLine = New System.Windows.Forms.Button
  106.         Me.cmCreateCircle = New System.Windows.Forms.Button
  107.         Me.cmSelect = New System.Windows.Forms.Button
  108.         Me.label2 = New System.Windows.Forms.Label
  109.         Me.label3 = New System.Windows.Forms.Label
  110.         Me.label1 = New System.Windows.Forms.Label
  111.         Me.cmRefresh = New System.Windows.Forms.Button
  112.         Me.GroupBox1.SuspendLayout()
  113.         Me.GroupBox2.SuspendLayout()
  114.         Me.SuspendLayout()
  115.         '
  116.         'GroupBox1
  117.         '
  118.         Me.GroupBox1.Controls.Add(Me.cmCreateTCApp)
  119.         Me.GroupBox1.Location = New System.Drawing.Point(32, 16)
  120.         Me.GroupBox1.Name = "GroupBox1"
  121.         Me.GroupBox1.Size = New System.Drawing.Size(200, 64)
  122.         Me.GroupBox1.TabIndex = 0
  123.         Me.GroupBox1.TabStop = False
  124.         Me.GroupBox1.Text = "Application"
  125.         '
  126.         'cmCreateTCApp
  127.         '
  128.         Me.cmCreateTCApp.Location = New System.Drawing.Point(16, 24)
  129.         Me.cmCreateTCApp.Name = "cmCreateTCApp"
  130.         Me.cmCreateTCApp.Size = New System.Drawing.Size(80, 24)
  131.         Me.cmCreateTCApp.TabIndex = 0
  132.         Me.cmCreateTCApp.Text = "Create"
  133.         '
  134.         'GroupBox2
  135.         '
  136.         Me.GroupBox2.Controls.Add(Me.cmNewDrawing)
  137.         Me.GroupBox2.Controls.Add(Me.cmCloseDrawing)
  138.         Me.GroupBox2.Location = New System.Drawing.Point(280, 16)
  139.         Me.GroupBox2.Name = "GroupBox2"
  140.         Me.GroupBox2.Size = New System.Drawing.Size(200, 64)
  141.         Me.GroupBox2.TabIndex = 0
  142.         Me.GroupBox2.TabStop = False
  143.         Me.GroupBox2.Text = "Drawing"
  144.         '
  145.         'cmNewDrawing
  146.         '
  147.         Me.cmNewDrawing.Location = New System.Drawing.Point(16, 24)
  148.         Me.cmNewDrawing.Name = "cmNewDrawing"
  149.         Me.cmNewDrawing.Size = New System.Drawing.Size(80, 24)
  150.         Me.cmNewDrawing.TabIndex = 0
  151.         Me.cmNewDrawing.Text = "New"
  152.         '
  153.         'cmCloseDrawing
  154.         '
  155.         Me.cmCloseDrawing.Location = New System.Drawing.Point(104, 24)
  156.         Me.cmCloseDrawing.Name = "cmCloseDrawing"
  157.         Me.cmCloseDrawing.Size = New System.Drawing.Size(80, 24)
  158.         Me.cmCloseDrawing.TabIndex = 0
  159.         Me.cmCloseDrawing.Text = "Close"
  160.         '
  161.         'picView
  162.         '
  163.         Me.picView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
  164.         Me.picView.Location = New System.Drawing.Point(8, 168)
  165.         Me.picView.Name = "picView"
  166.         Me.picView.Size = New System.Drawing.Size(584, 432)
  167.         Me.picView.TabIndex = 1
  168.         Me.picView.TabStop = False
  169.         '
  170.         'StatusBar1
  171.         '
  172.         Me.StatusBar1.Location = New System.Drawing.Point(0, 605)
  173.         Me.StatusBar1.Name = "StatusBar1"
  174.         Me.StatusBar1.Size = New System.Drawing.Size(912, 24)
  175.         Me.StatusBar1.TabIndex = 2
  176.         '
  177.         'propsPalette
  178.         '
  179.         Me.propsPalette.ImageIndex = -1
  180.         Me.propsPalette.Location = New System.Drawing.Point(608, 168)
  181.         Me.propsPalette.Name = "propsPalette"
  182.         Me.propsPalette.SelectedImageIndex = -1
  183.         Me.propsPalette.Size = New System.Drawing.Size(288, 432)
  184.         Me.propsPalette.TabIndex = 3
  185.         '
  186.         'cmZoomIn
  187.         '
  188.         Me.cmZoomIn.Location = New System.Drawing.Point(16, 128)
  189.         Me.cmZoomIn.Name = "cmZoomIn"
  190.         Me.cmZoomIn.Size = New System.Drawing.Size(80, 24)
  191.         Me.cmZoomIn.TabIndex = 0
  192.         Me.cmZoomIn.Text = "Zoom In"
  193.         '
  194.         'cmZoomOut
  195.         '
  196.         Me.cmZoomOut.Location = New System.Drawing.Point(104, 128)
  197.         Me.cmZoomOut.Name = "cmZoomOut"
  198.         Me.cmZoomOut.Size = New System.Drawing.Size(80, 24)
  199.         Me.cmZoomOut.TabIndex = 0
  200.         Me.cmZoomOut.Text = "Zoom Out"
  201.         '
  202.         'cmZoomExtents
  203.         '
  204.         Me.cmZoomExtents.Location = New System.Drawing.Point(192, 128)
  205.         Me.cmZoomExtents.Name = "cmZoomExtents"
  206.         Me.cmZoomExtents.Size = New System.Drawing.Size(88, 24)
  207.         Me.cmZoomExtents.TabIndex = 0
  208.         Me.cmZoomExtents.Text = "Zoom Extents"
  209.         '
  210.         'cmCreateLine
  211.         '
  212.         Me.cmCreateLine.Location = New System.Drawing.Point(288, 128)
  213.         Me.cmCreateLine.Name = "cmCreateLine"
  214.         Me.cmCreateLine.Size = New System.Drawing.Size(80, 24)
  215.         Me.cmCreateLine.TabIndex = 0
  216.         Me.cmCreateLine.Text = "Add Line"
  217.         '
  218.         'cmCreateCircle
  219.         '
  220.         Me.cmCreateCircle.Location = New System.Drawing.Point(376, 128)
  221.         Me.cmCreateCircle.Name = "cmCreateCircle"
  222.         Me.cmCreateCircle.Size = New System.Drawing.Size(80, 24)
  223.         Me.cmCreateCircle.TabIndex = 0
  224.         Me.cmCreateCircle.Text = "Add Circle"
  225.         '
  226.         'cmSelect
  227.         '
  228.         Me.cmSelect.Location = New System.Drawing.Point(472, 128)
  229.         Me.cmSelect.Name = "cmSelect"
  230.         Me.cmSelect.Size = New System.Drawing.Size(80, 24)
  231.         Me.cmSelect.TabIndex = 0
  232.         Me.cmSelect.Text = "Select"
  233.         '
  234.         'label2
  235.         '
  236.         Me.label2.Location = New System.Drawing.Point(16, 96)
  237.         Me.label2.Name = "label2"
  238.         Me.label2.TabIndex = 7
  239.         Me.label2.Text = "Active Tool :"
  240.         '
  241.         'label3
  242.         '
  243.         Me.label3.Location = New System.Drawing.Point(144, 96)
  244.         Me.label3.Name = "label3"
  245.         Me.label3.Size = New System.Drawing.Size(208, 23)
  246.         Me.label3.TabIndex = 8
  247.         '
  248.         'label1
  249.         '
  250.         Me.label1.Location = New System.Drawing.Point(608, 136)
  251.         Me.label1.Name = "label1"
  252.         Me.label1.Size = New System.Drawing.Size(144, 24)
  253.         Me.label1.TabIndex = 9
  254.         Me.label1.Text = "Properties:"
  255.         '
  256.         'cmRefresh
  257.         '
  258.         Me.cmRefresh.Location = New System.Drawing.Point(472, 96)
  259.         Me.cmRefresh.Name = "cmRefresh"
  260.         Me.cmRefresh.Size = New System.Drawing.Size(80, 24)
  261.         Me.cmRefresh.TabIndex = 10
  262.         Me.cmRefresh.Text = "Refresh"
  263.         '
  264.         'Form1
  265.         '
  266.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  267.         Me.ClientSize = New System.Drawing.Size(912, 629)
  268.         Me.Controls.Add(Me.cmRefresh)
  269.         Me.Controls.Add(Me.label1)
  270.         Me.Controls.Add(Me.label3)
  271.         Me.Controls.Add(Me.label2)
  272.         Me.Controls.Add(Me.propsPalette)
  273.         Me.Controls.Add(Me.StatusBar1)
  274.         Me.Controls.Add(Me.picView)
  275.         Me.Controls.Add(Me.GroupBox1)
  276.         Me.Controls.Add(Me.GroupBox2)
  277.         Me.Controls.Add(Me.cmZoomIn)
  278.         Me.Controls.Add(Me.cmZoomOut)
  279.         Me.Controls.Add(Me.cmZoomExtents)
  280.         Me.Controls.Add(Me.cmCreateLine)
  281.         Me.Controls.Add(Me.cmCreateCircle)
  282.         Me.Controls.Add(Me.cmSelect)
  283.         Me.Name = "Form1"
  284.         Me.Text = "Form1"
  285.         Me.GroupBox1.ResumeLayout(False)
  286.         Me.GroupBox2.ResumeLayout(False)
  287.         Me.ResumeLayout(False)
  288.  
  289.     End Sub
  290.  
  291. #End Region
  292.  
  293.     Sub EnableButtons(ByVal bVal As Boolean)
  294.  
  295.         cmCloseDrawing.Enabled = bVal
  296.         cmZoomIn.Enabled = bVal
  297.         cmZoomOut.Enabled = bVal
  298.         cmZoomExtents.Enabled = bVal
  299.         cmCreateLine.Enabled = bVal
  300.         cmCreateCircle.Enabled = bVal
  301.         cmSelect.Enabled = bVal
  302.         cmRefresh.Enabled = bVal
  303.         m_iActiveTool = ActiveTool.iSelectTool
  304.         UpdatePrompt()
  305.     End Sub
  306.     Sub UpdatePrompt()
  307.         StatusBar1.Text = ""
  308.         Select Case m_iActiveTool
  309.             Case ActiveTool.iSelectTool
  310.                 StatusBar1.Text = "Select Object"
  311.                 label3.Text = "Select Tool"
  312.             Case ActiveTool.iAddLineSingleTool
  313.                 If (m_bDrag = False) Then
  314.                     StatusBar1.Text = "Define the start point of the line"
  315.                     label3.Text = "Add Single Line"
  316.                 Else
  317.                     StatusBar1.Text = "Define the end point of the line"
  318.                     label3.Text = "Add Single Line"
  319.                 End If
  320.             Case ActiveTool.iAddCircleCenterAndPoint
  321.                 If (m_bDrag = False) Then
  322.                     StatusBar1.Text = "Define the center point of the circle"
  323.                     label3.Text = "Add Circle Center and Point"
  324.                 Else
  325.                     StatusBar1.Text = "Define a second point of the circle's circumferences"
  326.                     label3.Text = "Add Circle Center and Point"
  327.                 End If
  328.         End Select
  329.     End Sub
  330.     Sub FillPropertiesPalette(ByVal gxGraphic As IMSIGX.IGraphic)
  331.         ClearPropertiesPalette()
  332.         If gxGraphic Is Nothing Then
  333.             Return
  334.         End If
  335.         '// fill common info
  336.         Dim pRootNode As TreeNode, pchildNode As TreeNode
  337.         Dim gxVertices As IMSIGX.Vertices
  338.         Dim gxVertex As IMSIGX.IVertex
  339.         Dim var As Object
  340.         Dim vardblVal As Double
  341.         Dim radius As Double
  342.         Dim xCenter As Double, yCenter As Double, X As Double, Y As Double, Z As Double
  343.         vardblVal = 0
  344.         pRootNode = propsPalette.Nodes.Add("General")
  345.         pRootNode.Nodes.Add("GraphicID = " + gxGraphic.ID.ToString())
  346.         pRootNode.Nodes.Add("Type = " + gxGraphic.Type.ToString())
  347.         pRootNode = propsPalette.Nodes.Add("Geometry Information")
  348.         gxVertices = gxGraphic.Vertices
  349.         If (gxGraphic.TypeByValue = IMSIGX.ImsiGraphicType.imsiArc) Then
  350.             pchildNode = pRootNode.Nodes.Add("Center")
  351.             var = 0
  352.             gxVertex = gxVertices.Item(var)
  353.             xCenter = gxVertex.X
  354.             yCenter = gxVertex.Y
  355.             vardblVal = gxVertex.X
  356.             pchildNode.Nodes.Add("X = " + vardblVal.ToString())
  357.             vardblVal = gxVertex.Y
  358.             pchildNode.Nodes.Add("Y = " + vardblVal.ToString())
  359.             pchildNode.Nodes.Add("Z = 0")
  360.  
  361.             var = 1
  362.             gxVertex = gxVertices.Item(var)
  363.             X = gxVertex.X
  364.             Y = gxVertex.Y
  365.             radius = System.Math.Sqrt((xCenter - X) * (xCenter - X) + (yCenter - Y) * (yCenter - Y))
  366.             pchildNode = pRootNode.Nodes.Add("Radius " + radius.ToString())
  367.  
  368.         ElseIf (gxGraphic.TypeByValue = IMSIGX.ImsiGraphicType.imsiPolyline) Then
  369.  
  370.             Dim n As Integer, i As Integer
  371.             n = gxVertices.Count
  372.             pRootNode = pRootNode.Nodes.Add("Vertices")
  373.             For i = 0 To n - 1
  374.                 var = i
  375.                 gxVertex = gxVertices.Item(var)
  376.                 pchildNode = pRootNode.Nodes.Add("V " + var.ToString())
  377.                 X = gxVertex.X
  378.                 Y = gxVertex.Y
  379.                 Z = gxVertex.Z
  380.                 pchildNode.Nodes.Add("X = " + X.ToString())
  381.                 pchildNode.Nodes.Add("Y = " + Y.ToString())
  382.                 pchildNode.Nodes.Add("Z = " + Z.ToString())
  383.             Next i
  384.         End If
  385.         gxGraphic.Drawing.Graphics.Unselect()
  386.         gxGraphic.Selected = True
  387.         tcApp.m_gxView.Refresh()
  388.         propsPalette.ExpandAll()
  389.     End Sub
  390.     Sub ClearPropertiesPalette()
  391.         propsPalette.Nodes.Clear()
  392.     End Sub
  393.  
  394.     Private Sub cmCreateTCApp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmCreateTCApp.Click
  395.         tcApp.CreateGxApp()
  396.     End Sub
  397.  
  398.     Private Sub cmNewDrawing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmNewDrawing.Click
  399.         tcApp.CreateNewDrawing()
  400.         Dim pProp As IMSIGX.Property
  401.         Dim varVal As Object
  402.         varVal = "PaperColor"
  403.         Dim lcolor As Integer
  404.         pProp = tcApp.m_gxApp.Properties.Item(varVal)
  405.         lcolor = pProp.Value '.get_Value(0)
  406.         m_BackgroundColor = picView.BackColor
  407.         picView.BackColor = System.Drawing.ColorTranslator.FromWin32(lcolor)
  408.         pPenBackground = New Pen(picView.BackColor, 1)
  409.  
  410.  
  411.         tcApp.CreateGxView(picView.Handle.ToInt32)
  412.         tcApp.m_gxView.ZoomToExtents()
  413.         EnableButtons(True)
  414.         Me.Text = sTitle + " ------ " + tcApp.m_gxDrawing.Name
  415.  
  416.     End Sub
  417.  
  418.     Private Sub cmCloseDrawing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmCloseDrawing.Click
  419.         m_bDrag = False
  420.         pPenBackground.Dispose()
  421.         tcApp.m_gxDrawing.Close()
  422.         tcApp.m_gxDrawing = Nothing
  423.         tcApp.m_gxView = Nothing
  424.         EnableButtons(False)
  425.         Form1.ActiveForm.Text = sTitle
  426.         picView.BackColor = m_BackgroundColor
  427.         picView.Refresh()
  428.         StatusBar1.Text = ""
  429.     End Sub
  430.  
  431.     Private Sub cmZoomIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmZoomIn.Click
  432.         tcApp.Zoom(0.8)
  433.         picView.Refresh()
  434.         tcApp.m_gxView.Refresh()
  435.     End Sub
  436.  
  437.     Private Sub cmZoomOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmZoomOut.Click
  438.         tcApp.Zoom(1.2)
  439.         picView.Refresh()
  440.         tcApp.m_gxView.Refresh()
  441.     End Sub
  442.     Private Sub cmZoomExtents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmZoomExtents.Click
  443.         If Not tcApp.m_gxView Is Nothing Then
  444.             picView.Refresh()
  445.             tcApp.m_gxView.ZoomToExtents()
  446.         End If
  447.  
  448.     End Sub
  449.     Private Sub cmCreateLine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmCreateLine.Click
  450.         tcApp.m_gxDrawing.Graphics.Unselect()
  451.         tcApp.m_gxView.Refresh()
  452.         m_iActiveTool = ActiveTool.iAddLineSingleTool
  453.         UpdatePrompt()
  454.     End Sub
  455.     Private Sub cmCreateCircle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmCreateCircle.Click
  456.         tcApp.m_gxDrawing.Graphics.Unselect()
  457.         tcApp.m_gxView.Refresh()
  458.         m_iActiveTool = ActiveTool.iAddCircleCenterAndPoint
  459.         UpdatePrompt()
  460.     End Sub
  461.  
  462.     Private Sub cmSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmSelect.Click
  463.         StatusBar1.Text = "Select object"
  464.         m_iActiveTool = ActiveTool.iSelectTool
  465.         UpdatePrompt()
  466.         FillPropertiesPalette(Nothing)
  467.     End Sub
  468.  
  469.     Private Sub picView_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picView.MouseDown
  470.         Dim gxGraphic As IMSIGX.IGraphic
  471.         Dim mouseX As Integer
  472.         Dim mouseY As Integer
  473.         mouseX = e.X
  474.         mouseY = e.Y
  475.         If tcApp.m_gxView Is Nothing Then
  476.             Return
  477.         End If
  478.         If (e.Button = MouseButtons.Left) Then
  479.             If (m_iActiveTool <> ActiveTool.iSelectTool) Then
  480.                 '// if firstPointX nad firstPointY equal -1 it means that tool just started and 
  481.                 '// is in first click mode
  482.                 If (firstPointY = -1 And firstPointX = -1) Then
  483.                     '// store coordinates of first click
  484.                     firstPointX = mouseX
  485.                     firstPointY = mouseY
  486.                     '// switch to second click mode
  487.                     m_bDrag = True
  488.                     UpdatePrompt()
  489.                     Return
  490.                 End If
  491.             End If
  492.  
  493.             Select Case (m_iActiveTool)
  494.                 Case ActiveTool.iSelectTool
  495.                     Dim gxSelectedGraphic As IMSIGX.IGraphic
  496.                     tcApp.m_gxDrawing.Graphics.Unselect()
  497.                     gxSelectedGraphic = tcApp.SelectGraphic(mouseX, mouseY)
  498.                     FillPropertiesPalette(gxSelectedGraphic)
  499.                     tcApp.m_gxView.Refresh()
  500.  
  501.                 Case ActiveTool.iAddLineSingleTool
  502.                     gxGraphic = tcApp.AddLineSingle(firstPointX, firstPointY, mouseX, mouseY)
  503.                     m_bDrag = False
  504.                     firstPointX = -1
  505.                     firstPointY = -1
  506.                     previousMoveX = -1
  507.                     previousMoveY = -1
  508.  
  509.                 Case ActiveTool.iAddCircleCenterAndPoint
  510.                     gxGraphic = tcApp.AddCircleCenterAndPoint(firstPointX, firstPointY, mouseX, mouseY)
  511.                     m_bDrag = False
  512.                     firstPointX = -1
  513.                     firstPointY = -1
  514.                     previousMoveX = -1
  515.                     previousMoveY = -1
  516.             End Select
  517.             picView.Refresh()
  518.             tcApp.m_gxView.Refresh()
  519.             UpdatePrompt()
  520.             Return
  521.         End If
  522.     End Sub
  523.  
  524.     Private Sub picView_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picView.MouseMove
  525.         UpdatePrompt()
  526.         If (m_bDrag = False) Then
  527.             Return
  528.         End If
  529.         Dim mouseX As Integer
  530.         Dim mouseY As Integer
  531.         Dim radius As Integer
  532.         mouseX = e.X
  533.         mouseY = e.Y
  534.  
  535.         radius = 0
  536.  
  537.         Select Case (m_iActiveTool)
  538.             Case ActiveTool.iAddLineSingleTool
  539.                 If (m_bDrag = True) Then
  540.                     '// draw previous state of line with background color to hide it
  541.                     pGraphics.DrawLine(pPenBackground, firstPointX, firstPointY, previousMoveX, previousMoveY)
  542.                     '// draw current staet of line
  543.                     pGraphics.DrawLine(pPen, firstPointX, firstPointY, mouseX, mouseY)
  544.                 End If
  545.             Case ActiveTool.iAddCircleCenterAndPoint
  546.                 '// calculate radius for previous state of the circle
  547.                 radius = System.Math.Sqrt((firstPointX - previousMoveX) * (firstPointX - previousMoveX) + (firstPointY - previousMoveY) * (firstPointY - previousMoveY))
  548.                 If (radius <> 0) Then
  549.                     '// hide previous state of circle by draw it with background color
  550.                     pGraphics.DrawArc(pPenBackground, firstPointX - radius, firstPointY - radius, 2 * radius, 2 * radius, 0, 360)
  551.                 End If
  552.                 '// calculate radius of circle for current state
  553.                 radius = System.Math.Sqrt((firstPointX - mouseX) * (firstPointX - mouseX) + (firstPointY - mouseY) * (firstPointY - mouseY))
  554.                 If (radius <> 0) Then
  555.                     '// draw current state of the circle
  556.                     pGraphics.DrawArc(pPen, firstPointX - radius, firstPointY - radius, 2 * radius, 2 * radius, 0, 360)
  557.                 End If
  558.  
  559.         End Select
  560.         previousMoveX = mouseX
  561.         previousMoveY = mouseY
  562.         If Not tcApp.m_gxView Is Nothing Then
  563.             tcApp.m_gxView.Refresh()
  564.         End If
  565.  
  566.     End Sub
  567.  
  568.     Private Sub cmRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmRefresh.Click
  569.         tcApp.m_gxView.Refresh()
  570.         'picView.Refresh()
  571.     End Sub
  572.  
  573.     Private Sub picView_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picView.Paint
  574.         ' do not allow windows to perform paint of our PictureBox control we use for preview otherwise we wil see nothing
  575.         Return
  576.     End Sub
  577. End Class
  578.